[correlationId] Make correlationId a required parameter on AuthError constructors (breaking)#8609
[correlationId] Make correlationId a required parameter on AuthError constructors (breaking)#8609sameerag wants to merge 19 commits into
Conversation
Adds an optional correlationId parameter to createAuthError, createClientAuthError, createClientConfigurationError, createInteractionRequiredAuthError, createBrowserAuthError, createBrowserConfigurationAuthError, and createNativeAuthError. Updates msal-browser and msal-common call sites to forward the current request correlationId so thrown errors carry it for telemetry/debugging.
There was a problem hiding this comment.
Pull request overview
This PR improves MSAL telemetry/debuggability by propagating the current request correlationId into errors created via msal-common/msal-browser error factory helpers, and updates internal throw sites and unit tests accordingly.
Changes:
- Add optional
correlationIdparameters to several error creation helpers and forwardcorrelationIdat key throw sites. - Update native broker error translation (
createNativeAuthError) to applycorrelationIdacross translated error types. - Add/extend unit tests to verify
correlationIdbehavior for updated helpers.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/msal-common/test/error/InteractionRequiredAuthError.spec.ts | Adds tests asserting correlationId behavior for interaction-required error factory. |
| lib/msal-common/test/error/ClientConfigurationError.spec.ts | Adds tests asserting correlationId behavior for client configuration error factory. |
| lib/msal-common/test/error/ClientAuthError.spec.ts | Adds tests asserting correlationId behavior for client auth error factory. |
| lib/msal-common/test/error/AuthError.spec.ts | Adds tests asserting correlationId behavior for base auth error factory. |
| lib/msal-common/src/error/InteractionRequiredAuthError.ts | Extends interaction-required error factory signature to accept correlationId. |
| lib/msal-common/src/error/ClientConfigurationError.ts | Extends configuration error factory signature to accept/set correlationId. |
| lib/msal-common/src/error/ClientAuthError.ts | Extends client auth error factory signature to accept/set correlationId. |
| lib/msal-common/src/error/AuthError.ts | Extends base auth error factory signature to accept/set correlationId. |
| lib/msal-common/src/client/SilentFlowClient.ts | Forwards request.correlationId when throwing client auth errors. |
| lib/msal-common/src/client/RefreshTokenClient.ts | Forwards request.correlationId when throwing interaction-required errors. |
| lib/msal-common/src/client/AuthorizationCodeClient.ts | Forwards request.correlationId when throwing client/configuration errors. |
| lib/msal-browser/test/error/NativeAuthError.spec.ts | Adds tests asserting correlationId is preserved on translated native errors. |
| lib/msal-browser/test/error/BrowserConfigurationAuthError.spec.ts | Adds tests asserting correlationId behavior for browser configuration error factory. |
| lib/msal-browser/test/error/BrowserAuthError.spec.ts | Adds tests asserting correlationId behavior for browser auth error factory. |
| lib/msal-browser/src/interaction_client/SilentAuthCodeClient.ts | Forwards correlationId into thrown browser auth errors. |
| lib/msal-browser/src/interaction_client/PopupClient.ts | Forwards correlationId into thrown browser auth errors in popup flows. |
| lib/msal-browser/src/interaction_client/PlatformAuthInteractionClient.ts | Forwards correlationId into thrown common/browser errors in platform auth flows. |
| lib/msal-browser/src/interaction_client/BaseInteractionClient.ts | Forwards correlationId into thrown common configuration errors. |
| lib/msal-browser/src/error/NativeAuthError.ts | Extends native error translation to accept/apply correlationId. |
| lib/msal-browser/src/error/BrowserConfigurationAuthError.ts | Extends browser configuration error factory to accept/set correlationId. |
| lib/msal-browser/src/error/BrowserAuthError.ts | Extends browser auth error factory to accept/set correlationId. |
| lib/msal-browser/src/controllers/StandardController.ts | Forwards correlationId into thrown common/browser errors in controller paths. |
| lib/msal-browser/src/broker/nativeBroker/PlatformAuthExtensionHandler.ts | Forwards correlationId when translating/throwing native and auth errors. |
| lib/msal-browser/src/broker/nativeBroker/PlatformAuthDOMHandler.ts | Forwards correlationId when translating/throwing native and auth errors. |
| change/@azure-msal-common-151e2ba1-220e-4a47-a4dc-e421d262da2a.json | Adds patch changefile for msal-common. |
| change/@azure-msal-browser-7c559b7a-066d-486b-b68f-4b4359e3f053.json | Adds patch changefile for msal-browser. |
| export function createAuthError( | ||
| code: string, | ||
| additionalMessage?: string | ||
| additionalMessage?: string, | ||
| correlationId?: string | ||
| ): AuthError { |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…tors Breaking change: correlationId is now a mandatory positional parameter (position 2, before optional errorMessage/additionalMessage) on: - AuthError, ClientAuthError, ClientConfigurationError - InteractionRequiredAuthError, ServerError - JoseHeaderError, PlatformBrokerError The setCorrelationId() method has been removed from AuthError. Callers should assign to the public correlationId field directly if they need to set it after construction. All factory functions (createAuthError, createClientAuthError, createClientConfigurationError, createInteractionRequiredAuthError, createJoseHeaderError) now require correlationId as the second argument.
|
@copilot What are these outstanding changes? |
Only one code-review item is still outstanding on this PR: updating |
|
@copilot On the local branch I mean |
Locally there are no outstanding uncommitted changes right now — working tree is clean on |
|
@copilot Can we please collapse all PRs into one, as the changes are still many and would like a central place to handle all of them? |
Yes — we can consolidate. I can stop the stacked approach and put the remaining correlationId changes into this single PR so there’s one central place to review. I can’t merge/close PRs directly from here, so once we move the remaining changes here, please close the other stacked PRs. |
|
@copilot Have you checked it in and made the changes in the PR notes + change files? |
Code/check-ins are done, and the change files are updated (including the #8609 link format). PR notes are not yet updated to remove the old stacked/TBD wording — that still needs to be adjusted in the PR description text. |
|
@copilot Can we update the PR description please? |
Yes — I can prepare the updated text right away. I don’t have a direct tool here to edit the PR body itself, so please paste this updated description into the PR notes and I’ll keep subsequent updates aligned to it: SummaryBreaking change. Makes Previously Scope of this PRThis PR now serves as the single consolidated PR for the correlationId error propagation work (instead of the original stacked split). Changes
|
|
@copilot Can we close the remaining PRs? |
Summary
** Makes
correlationIda required parameter on theAuthErrorconstructor (and all subclass error constructors) across every MSAL package. This ensures thrown errors carry correlation context consistently for telemetry and debugging.Previously
correlationIdwas attached after construction viasetCorrelationId(), which was inconsistently called. That helper is removed; the value is now required at construction.Scope of this PR
This PR now serves as the single consolidated PR for the correlationId error propagation work (instead of the original stacked split).
Changes
@azure/msal-commonAuthErrorconstructor signature changed from(errorCode, errorMessage?, suberror?)to(errorCode, correlationId, errorMessage?, suberror?).ClientAuthError,ClientConfigurationError,InteractionRequiredAuthError,ServerError,JoseHeaderError,NetworkError,CacheError.setCorrelationId()removed.correlationId(or""where not yet in scope).@azure/msal-browsercorrelationId.@azure/msal-node,@azure/msal-node-extensions,@azure/msal-react,@azure/msal-angularcorrelationId(or""where not in scope).Change files
Migration